import type { FormInstance } from 'element-plus'

export function useForm() {
  const validate = (formRef?: FormInstance) => useValidate(formRef)

  return {
    validate
  }
}

const useValidate = (formRef?: FormInstance) => {
  const onCheck = formRef?.validate(async (valid) => {
    return await valid
  })

  return onCheck || true
}
